Socket
Socket
Sign inDemoInstall

@thi.ng/checks

Package Overview
Dependencies
1
Maintainers
0
Versions
158
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/checks


Version published
Maintainers
0
Install size
141 kB
Created

Package description

What is @thi.ng/checks?

@thi.ng/checks is a utility library for various type checks and predicates in JavaScript. It provides a wide range of functions to check types, values, and conditions, making it easier to validate data and ensure code correctness.

What are @thi.ng/checks's main functionalities?

Type Checks

This feature allows you to check the type of a given value. The `isString` function checks if the value is a string, and the `isNumber` function checks if the value is a number.

const { isString, isNumber } = require('@thi.ng/checks');

console.log(isString('hello')); // true
console.log(isNumber(123)); // true
console.log(isNumber('123')); // false

Array Checks

This feature provides functions to check if a value is an array and if an array is empty. The `isArray` function checks if the value is an array, and the `isEmptyArray` function checks if the array is empty.

const { isArray, isEmptyArray } = require('@thi.ng/checks');

console.log(isArray([1, 2, 3])); // true
console.log(isEmptyArray([])); // true
console.log(isEmptyArray([1])); // false

Object Checks

This feature includes functions to check if a value is an object and if an object is empty. The `isObject` function checks if the value is an object, and the `isEmptyObject` function checks if the object is empty.

const { isObject, isEmptyObject } = require('@thi.ng/checks');

console.log(isObject({ a: 1 })); // true
console.log(isEmptyObject({})); // true
console.log(isEmptyObject({ a: 1 })); // false

Function Checks

This feature provides a function to check if a value is a function. The `isFunction` function checks if the value is a function.

const { isFunction } = require('@thi.ng/checks');

console.log(isFunction(function() {})); // true
console.log(isFunction(() => {})); // true
console.log(isFunction(123)); // false

String Checks

This feature includes functions to check if a value is a string and if a string is empty. The `isString` function checks if the value is a string, and the `isEmptyString` function checks if the string is empty.

const { isString, isEmptyString } = require('@thi.ng/checks');

console.log(isString('hello')); // true
console.log(isEmptyString('')); // true
console.log(isEmptyString('hello')); // false

Other packages similar to @thi.ng/checks

Readme

Source

@thi.ng/checks

npm version npm downloads Mastodon Follow

[!NOTE] This is one of 189 standalone projects, maintained as part of the @thi.ng/umbrella monorepo and anti-framework.

🚀 Please help me to work full-time on these projects by sponsoring me on GitHub. Thank you! ❤️

About

Collection of 70+ type, feature & value checks.

Status

STABLE - used in production

Search or submit any issues for this package

Installation

yarn add @thi.ng/checks

ESM import:

import * as ch from "@thi.ng/checks";

Browser ESM import:

<script type="module" src="https://esm.run/@thi.ng/checks"></script>

JSDelivr documentation

For Node.js REPL:

const ch = await import("@thi.ng/checks");

Package sizes (brotli'd, pre-treeshake): ESM: 1.65 KB

Dependencies

API

Generated API docs

TODO

Authors

If this project contributes to an academic publication, please cite it as:

@misc{thing-checks,
  title = "@thi.ng/checks",
  author = "Karsten Schmidt and others",
  note = "https://thi.ng/checks",
  year = 2016
}

License

© 2016 - 2024 Karsten Schmidt // Apache License 2.0

Keywords

FAQs

Last updated on 29 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc